import requests
import json

# 发送post请求
response = requests.post('https://www.baidu.com/')

# 打印状态码
print(response)

# 打印相应内容
print(response.text)

# ----------------------

# 发送json数据的post请求

url = 'https://www.baidu.com/'
data = {'key': 'value'}
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'}
response = requests.post(url, json=json.dumps(data), headers=headers)
